import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Welcome from '../views/Welcome'
import Login from '../views/Login'
import List from '../views/artical/List'
import New from '../views/artical/New'
import Info from '../views/material/Info'
import Users from '../views/system/Users'
import Changepwd from '../views/material/Changepwd'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    redirect: '/welcome',
    children: [
      {
        path: '/welcome',
        component: Welcome
      },
      {
        path: '/users',
        component: Users
      },
      {
        path: '/artical/new',
        component: New
      },
      {
        path: '/artical/list',
        component: List
      },
      {
        path: '/basicinfo',
        component: Info
      },
      {
        path: '/changepassword',
        component: Changepwd
      }
    ]
  }
]

const router = new VueRouter({
  routes,
  mode: 'history'
})

const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

export default router
